﻿using IterationLife.Educations.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.Educations {
    /// <summary>
    /// 课程表数据传输对象扩展
    /// </summary>
    public static class CurriculumScheduleDtoExtension {
        /// <summary>
        /// 转换为课程表实体
        /// </summary>
        /// <param name="dto">课程表数据传输对象</param>
        public static CurriculumSchedule ToEntity( this CurriculumScheduleDto dto ) {
            if ( dto == null )
                return new CurriculumSchedule();
            return dto.MapTo( new CurriculumSchedule( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为课程表数据传输对象
        /// </summary>
        /// <param name="entity">课程表实体</param>
        public static CurriculumScheduleDto ToDto(this CurriculumSchedule entity) {
            if( entity == null )
                return new CurriculumScheduleDto();
            return entity.MapTo(new CurriculumScheduleDto());
        }
    }
}
